﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using WCFMINERP.COM;
using WCFMINERP.Contracts.DataContracts;
using WCFMINERP.Contracts.InterFaces;

namespace WCFMINERP.Factory.Presenter
{
    public class OrderInfoPresenter
    {


        ChannelFactory<Iorderinfo> _proxy;
        Iorderinfo _innerFactory;

        public OrderInfoPresenter()
        {
            _proxy = new ChannelFactory<Iorderinfo>("Iorderinfo");
            _innerFactory = _proxy.CreateChannel();
        }


        public List<Contracts.DataContracts.OrderInfo> GetOrderInfoData(int techid)
        {
            return _innerFactory.GetOrderInfoData(techid);
        }
        
        /// <summary>
        /// 提交流程
        /// </summary>
        /// <param name="orderProductCode"></param>
        /// <param name="techid"></param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public OrderInfo CommitTech(string orderProductCode, int techid, int userid,out string mess, out string imgpath)
        {
            mess = "";
            imgpath = "";
            try
            {
                return _innerFactory.CommitTech(orderProductCode, techid,userid,out mess, out imgpath);
            }
            catch (Exception ex)
            {
                WriteAnalyseLog.WriteLogFile(ex.Message);
                return new OrderInfo { Commit = false };
            }
        }

        /// <summary>
        /// 查询产品
        /// </summary>
        /// <param name="orderProductCode"></param>
        /// <param name="mess"></param>
        /// <returns></returns>
        public OrderInfo SercahProduct(string orderProductCode, out string mess)
        {
            mess = "";
            try
            {
                return _innerFactory.SercahProduct(orderProductCode, out mess);
            }
            catch (Exception ex)
            {
                WriteAnalyseLog.WriteLogFile(ex.Message);
                return new OrderInfo { Commit = false };
            }
        }
    }
}
